<?php
class redisdriver{
    public $data_redis;
    public $cache_redis;
    public $report_redis;

    public function InitDataRedis(){
        $redis_config = Config::$redis_data_config;
        $this->data_redis = new Redis();
        $redis_name = 'redis0';
        $ret = $this->data_redis->connect($redis_config[$redis_name]['host'],$redis_config[$redis_name]['port']);
        if (!$ret) {
            return false;
        }
        $ret = $this->data_redis->auth($redis_config[$redis_name]['pass']);
        if (!$ret) {
            return false;
        }
        $this->data_redis->select(0);
        return true;
    }
    
    public function InitCacheRedis(){
        $redis_config = Config::$redis_data_config;
        $this->cache_redis = new Redis();
        $redis_name = 'redis0';
        $ret = $this->cache_redis->connect($redis_config[$redis_name]['host'],$redis_config[$redis_name]['port']);
        if (!$ret) {
            return false;
        }
        $ret = $this->cache_redis->auth($redis_config[$redis_name]['pass']);
        if (!$ret) {
            return false;
        }
        $this->cache_redis->select(2);
        return true;
    }
    
    public function InitReportRedis(){
        $redis_config = Config::$redis_data_config;
        $this->report_redis = new Redis();
        $redis_name = 'redis0';
        $ret = $this->report_redis->connect($redis_config[$redis_name]['host'],$redis_config[$redis_name]['port']);
        if (!$ret) {
            return false;
        }
        $ret = $this->report_redis->auth($redis_config[$redis_name]['pass']);
        if (!$ret) {
            return false;
        }
        $this->report_redis->select(3);
        return true;
    }
    
    

}